// pages/teaAppstu/teaAppstu.js
Page({

  data: {
    ktId: '',
    listXs: [],
    ktmc: ''
  },
  onLoad: function(options) {
    this.setData({
      ktId: options._id,
      ktmc: options.ktmc
    })
  },
  onShow: function() {
    const that = this
    that.setData({
      listXs: []
    })
    wx.cloud.database({
      env: 'gtss-2b1812'
    }).collection('Option').where({
      topicId: that.data.ktId
    }).get().then(res => {
      for (var i = 0; i < res.data.length; i++) {
        wx.cloud.database({
          env: 'gtss-2b1812'
        }).collection('Student').doc(res.data[i].userId).field({
          _id: true,
          stuName: true
        }).get().then(res => {
          that.setData({
            listXs: that.data.listXs.concat(res.data)
          })
        })
      }
    })
  },
  funXsxq: function(e) {
    wx.navigateTo({
      url: '../teaStuxx/teaStuxx?stuId=' + e.currentTarget.dataset.id + '&topicId=' + this.data.ktId + '&ktmc=' + this.data.ktmc + '&from=appstu'
    })
  }
})